package br.com.yurikimo.ykkit;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

//...240x320 - 20px 320x480 - 25px 480x800+ - 38px

public class YKScreen{
	private static final int LOW_DPI_STATUS_BAR_HEIGHT = 19;
	private static final int MEDIUM_DPI_STATUS_BAR_HEIGHT = 25;
	private static final int HIGH_DPI_STATUS_BAR_HEIGHT = 38;

	public static final int SCREEN_GROUP_LOW = 1;
	public static final int SCREEN_GROUP_MEDIUM = 2;
	public static final int SCREEN_GROUP_HIGH = 3;
	
	public static YKSize getSize(){
    Display display = YKDirector.getActivity().getWindowManager().getDefaultDisplay(); 
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();
    
    DisplayMetrics displayMetrics = new DisplayMetrics();
		((WindowManager) YKDirector.getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics);

		int statusBarHeight;

		switch (screenWidth) {
		    case 480:
		        statusBarHeight = HIGH_DPI_STATUS_BAR_HEIGHT;
		        break;
		    case 320:
		        statusBarHeight = MEDIUM_DPI_STATUS_BAR_HEIGHT;
		        break;
		    case 240:
		        statusBarHeight = LOW_DPI_STATUS_BAR_HEIGHT;
		        break;
		    default:
		        statusBarHeight = MEDIUM_DPI_STATUS_BAR_HEIGHT;
		}    
		
		return new YKSize(screenWidth, screenHeight - statusBarHeight);
	}
	
	public static int getScreenGroup(){
    Display display = YKDirector.getActivity().getWindowManager().getDefaultDisplay(); 
    int screenWidth = display.getWidth();
    
		switch (screenWidth) {
		    case 480:
		        return SCREEN_GROUP_HIGH;
		    case 320:
		        return SCREEN_GROUP_MEDIUM;
		    case 240:
		        return SCREEN_GROUP_LOW;
		    default:
		    	return SCREEN_GROUP_MEDIUM;
		}    
	}
}
